package com.dhcc.bpm.modules.log.controller;

import io.swagger.annotations.Api;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import javax.validation.Valid;

import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dhcc.bpm.modules.log.entity.TpsPeak;
import com.dhcc.bpm.modules.log.vo.TpsPeakVO;
import com.dhcc.bpm.modules.log.service.ITpsPeakService;
import org.springblade.core.boot.ctrl.BladeController;

/**
 * tps峰值表 控制器
 *
 * @author xiafayu
 * @since 2021-05-31
 */
@RestController
@AllArgsConstructor
@RequestMapping("cbus-bpm-boot/tpspeak")
@Api(value = "tps峰值表", tags = "tps峰值表接口")
public class TpsPeakController extends BladeController {

	private ITpsPeakService tpsPeakService;

	/**
	 * 详情
	 */
	@GetMapping("/detail")
	@ApiOperationSupport(order = 1)
	@ApiOperation(value = "详情", notes = "传入tpsPeak")
	public R<TpsPeak> detail(TpsPeak tpsPeak) {
		TpsPeak detail = tpsPeakService.getOne(Condition.getQueryWrapper(tpsPeak));
		return R.data(detail);
	}

	/**
	 * 分页 tps峰值表
	 */
	@GetMapping("/list")
	@ApiOperationSupport(order = 2)
	@ApiOperation(value = "分页", notes = "传入tpsPeak")
	public R<IPage<TpsPeak>> list(TpsPeak tpsPeak, Query query) {
		IPage<TpsPeak> pages = tpsPeakService.page(Condition.getPage(query), Condition.getQueryWrapper(tpsPeak));
		return R.data(pages);
	}

	/**
	 * 自定义分页 tps峰值表
	 */
	@GetMapping("/page")
	@ApiOperationSupport(order = 3)
	@ApiOperation(value = "分页", notes = "传入tpsPeak")
	public R<IPage<TpsPeakVO>> page(TpsPeakVO tpsPeak, Query query) {
		IPage<TpsPeakVO> pages = tpsPeakService.selectTpsPeakPage(Condition.getPage(query), tpsPeak);
		return R.data(pages);
	}

	/**
	 * 新增 tps峰值表
	 */
	@PostMapping("/save")
	@ApiOperationSupport(order = 4)
	@ApiOperation(value = "新增", notes = "传入tpsPeak")
	public R save(@Valid @RequestBody TpsPeak tpsPeak) {
		return R.status(tpsPeakService.save(tpsPeak));
	}

	/**
	 * 修改 tps峰值表
	 */
	@PostMapping("/update")
	@ApiOperationSupport(order = 5)
	@ApiOperation(value = "修改", notes = "传入tpsPeak")
	public R update(@Valid @RequestBody TpsPeak tpsPeak) {
		return R.status(tpsPeakService.updateById(tpsPeak));
	}

	/**
	 * 新增或修改 tps峰值表
	 */
	@PostMapping("/submit")
	@ApiOperationSupport(order = 6)
	@ApiOperation(value = "新增或修改", notes = "传入tpsPeak")
	public R submit(@Valid @RequestBody TpsPeak tpsPeak) {
		return R.status(tpsPeakService.saveOrUpdate(tpsPeak));
	}

	
	/**
	 * 删除 tps峰值表
	 */
	@PostMapping("/remove")
	@ApiOperationSupport(order = 8)
	@ApiOperation(value = "删除", notes = "传入ids")
	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
		return R.status(tpsPeakService.removeByIds(Func.toLongList(ids)));
	}

	
}
